<template>
	<view class="bg-white u-padding-20">
		<!-- <u-navbar title="我的班级" :autoBack="false" safeAreaInsetTop fixed placeholder /> -->
		<view>
			<uni-card :cover="cover" 
				:title="displayTitle(item)"
				padding="0" v-for="(item,index) in list" 
				:subTitle="parseTime(item.startDate) + ' ~ ' + parseTime(item.endDate)"
				:key="index" :extra="item.courseName">
				<view>
					<u-cell-group>
						<u-cell  center size="large" :is-link="true" 
							:value="'学生数:' + item.studentCount + '人'" index="index" @click="showDetail(item.id)" :arrow="true">
							<view slot="label" class="line-height-view">班主任: {{item.teacherName}}</view>
							<view slot="label" class="line-height-view">{{item.remark ? item.remark : ""}}</view>
						</u-cell>
					</u-cell-group>
				</view>
			</uni-card>
			
			<view class="u-padding-30 bg-white" v-if="list.length == 0" >
				<u-empty mode="list" text="暂无班主任/上课老师/助教相关的班级信息"></u-empty>
			</view>
		</view>
	</view>
</template>
<script>
	import paginateMix from "@/mixins/paginateMixins.js"
	import request from '@/utils/request'
	import { parseTime} from '@/utils/zhanpeng.js'
	
	export default {
		mixins: [paginateMix],
		data() {
			return {
				checked: false,
				list: [],
			}
		},
		onLoad() {
			this.handleReq()
		},
		methods: {
			displayTitle(item) {
				return "班级：" + item.name + " " + (item.beOver ? '(已结课)' : '');
			},
			parseTime(itemTime) {
			  return parseTime(itemTime,'{y}-{m}-{d}');
			},
			handleReq() {
				request({url:'/erp/class/page4Teacher',data:{page: this.pageData.page}}).then( res => {
					if(!this.$common.handleResponseMsg(res)) return;
					this.list = this.list.concat(res.data.list)
					this.pageData.page = parseInt(res.page);
					this.pageData.lastPage = parseInt(res.pageCount);
				});
			},
			showDetail(id) {
				uni.navigateTo({
					url: `/pages/class/detail?classId=${id}`
				});
			},
			clickRight() {
				this.list = [];
				this.pageData.page = 1
				this.handleReq()
			},
			clickLeft() {
				uni.switchTab({
					url: '/pages/index/index'
				});
			}
		}
	}
</script>
<style lang="scss" scoped>
	.line-height-view {
		line-height:35px;
		height: 35px;
	}
</style>
